home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / BCCollec / Support / BCUnboun.h < prev   
Encoding:
Text File  |  1994-04-21  |  2.2 KB  |  78 lines  |  [TEXT/MPS ]

  1. //  The C++ Booch Components (Version 2.1)
  2. //  (C) Copyright 1990-1993 Grady Booch. All Rights Reserved.
  3. //
  4. //  BCUnboun.h
  5. //
  6. //  This file contains the declaration of the list-based class
  7. //  used for the representation of unbounded structures.
  8.  
  9. #ifndef BCUNBOUN_H
  10. #define BCUNBOUN_H 1
  11.  
  12. #include <stddef.h>
  13. #include "BCExcept.h"
  14. #include "BCNodes.h"
  15.  
  16. // Class denoting a list-based container
  17.  
  18. template<class Item, class StorageManager>
  19. class BC_TUnbounded {
  20. public:
  21.  
  22.   BC_TUnbounded();
  23.   BC_TUnbounded(const BC_TUnbounded<Item, StorageManager>&);
  24.   ~BC_TUnbounded();
  25.  
  26.   BC_TUnbounded<Item, StorageManager>& 
  27.     operator=(const BC_TUnbounded<Item, StorageManager>&);
  28.   BC_Boolean operator==(const BC_TUnbounded<Item, StorageManager>&) const;
  29.   BC_Boolean operator!=(const BC_TUnbounded<Item, StorageManager>& c) const
  30.     {return !operator==(c);} 
  31.   const Item& operator[](BC_Index index) const
  32.     {BC_Assert((index < Length()),
  33.                BC_XRangeError("BC_TUnbounded<>::operator[]", BC_kInvalidIndex));
  34.      return ItemAt(index);}
  35.   Item& operator[](BC_Index index)
  36.     {BC_Assert((index < Length()),
  37.                BC_XRangeError("BC_TUnbounded<>::operator[]", BC_kInvalidIndex));
  38.      return ItemAt(index);}
  39.  
  40.   void Clear();
  41.   void Insert(const Item&);
  42.   void Insert(const Item&, BC_Index before);
  43.   void Append(const Item&);
  44.   void Append(const Item&, BC_Index after);
  45.   void Remove(BC_Index at);
  46.   void Replace(BC_Index at, const Item&);
  47.  
  48.   BC_Index Length() const;
  49.   const Item& First() const
  50.     {BC_Assert(fSize, BC_XUnderflow("BC_TUnbounded<>::First()", BC_kEmpty));
  51.      return (fRep->fItem);}
  52.   Item& First()
  53.     {BC_Assert(fSize, BC_XUnderflow("BC_TUnbounded<>::First()", BC_kEmpty));
  54.      return (fRep->fItem);}
  55.   const Item& Last() const
  56.     {return (fLast->fItem);}
  57.   Item& Last()
  58.     {return (fLast->fItem);}
  59.   const Item& ItemAt(BC_Index index) const;
  60.   Item& ItemAt(BC_Index index);
  61.   BC_ExtendedIndex Location(const Item&, BC_Index start = 0) const;
  62.  
  63.   static void* operator new(size_t);
  64.   static void operator delete(void*, size_t);
  65.  
  66. protected:
  67.  
  68.   BC_TNode<Item, StorageManager>* fRep;
  69.   BC_TNode<Item, StorageManager>* fLast;
  70.   BC_Index fSize;
  71.  
  72.   BC_TNode<Item, StorageManager>* fCache;
  73.   BC_Index fCacheIndex;
  74.  
  75. };
  76.  
  77. #endif
  78.